<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('查看APP账号')"/>
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <input type="hidden" th:value="${accountId}" id="accountId"/>
        <input type="hidden" th:value="${accountType}" id="accountType"/>
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>
    </div>
</div>
<div th:include="include :: footer"></div>
<script th:inline="javascript">
    var prefix = ctx + "system/project";

    var isBanDatas = [[${@dict.getType('sys_proxy_user_is_ban')}]];
    var isStaffDatas = [[${@dict.getType('sys_proxy_user_is_staff')}]];


    $(function () {
        var options = {
            url: prefix + "/accountlist",
            showSearch: false,
            showRefresh: false,
            showToggle: false,
            showColumns: false,
            queryParams: {
                "accountId": $("#accountId").val(),
                "accountType": $("#accountType").val()
            },
            columns: [{
                checkbox: true
            },
                {
                    field: 'trueName',
                    title: '姓名'
                },
                {
                    field: 'phone',
                    title: '联系方式(登录账号)'
                },
                {
                    field: 'createTime',
                    title: '创建时间'
                },
                {
                    field: 'lastLoginTime',
                    title: '最新登录时间'
                },
                {
                    field: 'isStaff',
                    title: '是否员工',
                    align: 'center',
                    formatter: function (value, row, index) {
                        return $.table.selectDictLabel(isStaffDatas, value);
                    }
                },
                // {
                //     field: 'isBan',
                //     title: '状态',
                //     align: 'center',
                //     formatter: function (value, row, index) {
                //         return $.table.selectDictLabel(isBanDatas, value);
                //     }
                // },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function (value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-danger btn-xs" href="javascript:void(0)" onclick="delById(\'' + row.id + '\')" ><i class="fa fa-remove"></i>删除</a>');
                        return actions.join('');
                    }
                }]
        };
        $.table.init(options);
    });

    // 删除账号
    function delById(id) {
        var url = prefix + "/delAccount";
        var data = {
            "id": id,
        };
        $.modal.confirm("您确定删除吗？", function () {
            $.operate.submit(url, "post", "json", data);
        });
    }
</script>
</body>
</html>